import Vue from 'vue'
import VueRouter from 'vue-router'
import wordRemember from './wordRemember'
import reverse from './reverseWords'
import composition from './composition'
import superRead from './superRead'
import store from '@/store'
Vue.use(VueRouter)

  const routes = [
  {
    path: '/',
    name: 'Index',
    // redirect: '/wordRemember',
    component: () => import('../views/Home.vue')
  },
  {
    path: '/setting',
    name: 'setting',
    component: () => import('../views/Setting.vue')
  },
  ...wordRemember,
  ...reverse,
  ...composition,
  ...superRead,
  // {
  //   path: '/wordRemember',
  //   name: 'wordRemember',
  //   component: () => import('../views/wordRemember/index.vue')
  // },
  // {
  //   path: '/wordLexicon',
  //   name: 'wordLexicon',
  //   component: () => import('../views/wordRemember/wordLexicon.vue')
  // },
  // {
  //   path: '/wordList',
  //   name: 'wordList',
  //   component: () => import('../views/wordRemember/wordList.vue')
  // },
  // {
  //   path: '/familiar',
  //   name: 'familiar',
  //   component: () => import('../views/wordRemember/familiar.vue')
  // },
  // {
  //   path: '/beforeStudy',
  //   name: 'beforeStudy',
  //   component: () => import('../views/wordRemember/beforeStudy.vue')
  // },
  // {
  //   path: '/afterStudy',
  //   name: 'afterStudy',
  //   component: () => import('../views/wordRemember/afterStudy.vue')
  // },
  // {
  //   path: '/wordReport',
  //   name: 'wordReport',
  //   component: () => import('../views/wordRemember/wordReport.vue')
  // },
  // {
  //   path: '/selfStudy',
  //   name: 'selfStudy',
  //   component: () => import('../views/wordRemember/selfStudy.vue')
  // },
  // {
  //   path: '/noKown',
  //   name: 'noKown',
  //   component: () => import('../views/wordRemember/noKown.vue')
  // },
  // {
  //   path: '/wordMemory',
  //   name: 'wordMemory',
  //   meta: {
  //     keepAlive: true,
  //     isBack: true
  //   },
  //   component: () => import('../views/wordRemember/wordMemory.vue')
  // },
  // {
  //   path: '/wordIndex',
  //   name: 'wordIndex',
  //   component: () => import('../views/wordRemember/wordIndex.vue')
  // },
  // {
  //   path: '/smartIndex',
  //   name: 'smartIndex',
  //   component: () => import('../views/wordRemember/smartIndex.vue')
  // },
  // {
  //   path: '/simulatePaper',
  //   name: 'simulatePaper',
  //   component: () => import('../views/wordRemember/simulatePaper.vue')
  // },
  // {
  //   path: '/wordReview',
  //   name: 'wordReview',
  //   component: () => import('../views/wordRemember/wordReview.vue')
  // },
  // {
  //   path: '/wordGrade',
  //   name: 'wordGrade',
  //   component: () => import('../views/wordRemember/wordGrade.vue')
  // },
  // {
  //   path: '/list',
  //   name: 'list',
  //   component: () => import('../views/wordRemember/list.vue')
  // }
]
console.log(routes)
const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  console.log('路由切换', to.path)
  store.commit('setTranslateModal', {visible: false})
  store.commit('setReadBroadModal', {visible: false})
  store.commit('setGrammarExplain', false)
  store.commit('setGrammarSkill', false)
  let BSync = window.isBSync()
  let isController = window.isController()
  BSync && isController && BSync.socket.emit('sync:cmd', {
    cmd: 'ROUTER_CHANGE'
  })
  // 快点限制白名单放开
  if(/(((wordRemember|super-read)\/(beforeStudy|afterStudy|wordReview|wordMemory|simulatePaper|familiar))|((composition)\/(spell|breakTrain)))$/i.test(to.path)){
    window.__LIMIT_TIME__ = -1
  }else{
    delete window.__LIMIT_TIME__
  }
  next()
})

export default router
